﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TFhisto
{
    /// <summary>
    /// Represents a file that has changed
    /// </summary>
    public class FileChangeInfo
    {
        /// <summary>
        /// Full server path of the file
        /// <example>"$/BlogEngine.NET/src/Dev/BlogEngine1_5/BlogEngineWeb/login.aspx.cs"</example>
        /// </summary>
        public string FullPath
        { get; set; }

        /// <summary>
        /// Returns just the file. Using the FullPath example, just login.aspx.cs would be returned
        /// </summary>
        public string FileName
        {
            get
            {
                if (FullPath.Contains('/'))
                {
                    return FullPath.Substring(FullPath.LastIndexOf('/') + 1);
                }
                else
                {
                    return FullPath.Substring(FullPath.LastIndexOf('\\') + 1);
                }

            }
        }

        /// <summary>
        /// This is either Add, Edit, Branch or Delete
        /// </summary>
        public string ChangeType
        { get; set; }

        /// <summary>
        /// Used to display the list of files to select
        /// </summary>
        public bool Checked
        { get; set; }

        /// <summary>
        /// Used to identify if the file needs to be checked
        /// </summary>
        public bool Selected
        { get; set; }

        public override bool Equals(object obj)
        {
            bool isEqual = false;
            if (obj.GetType() == typeof(FileChangeInfo))
            {
                isEqual = ((FileChangeInfo)obj).FullPath.Equals(FullPath);
            }

            return isEqual;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
